﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Admin.master" AutoEventWireup="true" CodeFile="Banners.aspx.cs" Inherits="admin_Banners" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

    <script>
        $(document).ready(function() {
        $("#ctl00_ContentPlaceHolder1_gvBanners a").click(message);
        $("#ctl00_ContentPlaceHolder1_btnSave").click(validateInsert);
        $("#ctl00_ContentPlaceHolder1_gvBanners a").attr('class', 'button');
            $("#ctl00_ContentPlaceHolder1_gvBanners input[type='submit']").attr('class', 'button');
            $('#aspnetForm1').validate({
                rules: {
                    "ctl00$ContentPlaceHolder1$fpBanner": "required",
                    "ctl00$ContentPlaceHolder1$tbName": "required"
                },
                messages: {
                    "ctl00$ContentPlaceHolder1$tbName": "Enter valid link",
                    "ctl00$ContentPlaceHolder1$fpBanner": "Enter file for upload"
                }
            });
        });
    function message() {
        var answer = confirm("Are you sure you want to delete this banner?")
        return answer;
    }
    function validateInsert() {
        validated = false;
        if ($("#ctl00_ContentPlaceHolder1_fpBanner").val() == "") {
            validated = false;
            $('#ctl00_ContentPlaceHolder1_fpBanner-exists').remove();
            $('#ctl00_ContentPlaceHolder1_fpBanner').after('<label id="ctl00_ContentPlaceHolder1_fpBanner-exists" for="ctl00_ContentPlaceHolder1_fpBanner" generated="true" class="error" style="display: inline;">File is required</label>');
        }
        else {
            $('#ctl00_ContentPlaceHolder1_fpBanner-exists').remove();
            validated = true;
        }

        if ($("#ctl00_ContentPlaceHolder1_tbName").val() == "") {
            validated = false;
            $('#ctl00_ContentPlaceHolder1_tbName-exists').remove();
            $('#ctl00_ContentPlaceHolder1_tbName').after('<label id="ctl00_ContentPlaceHolder1_tbName-exists" for="ctl00_ContentPlaceHolder1_tbName" generated="true" class="error" style="display: inline;">link is required</label>');
        }
        else {
            $('#ctl00_ContentPlaceHolder1_tbName-exists').remove();
            validated = true;
        }
        if ($("#ctl00_ContentPlaceHolder1_tbOrder").val() != "" && isNaN(parseInt($("#ctl00_ContentPlaceHolder1_tbOrder").val())) == true) {
            validated = false;
            $('#ctl00_ContentPlaceHolder1_tbName-exists').remove();
            $('#ctl00_ContentPlaceHolder1_tbOrder').after('<label id="ctl00_ContentPlaceHolder1_tbOrder-exists" for="ctl00_ContentPlaceHolder1_tbOrder" generated="true" class="error" style="display: inline;">Must be numeric</label>');
        }
        else {
            $('#ctl00_ContentPlaceHolder1_tbOrder-exists').remove();
        }
        return validated;
    }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><br />
<div id="formDiv">
    <div class="inputDiv">
        <asp:Label ID="Label1" runat="server" class="tdLeftInside" for="" Text="file:"></asp:Label>
        <asp:FileUpload ID="fpBanner" CssClass="searcxBoxName" runat="server" Width="255px" />
    </div>
    <div style="clear:both"></div>
        <div class="inputDiv">
            <asp:Label ID="Label2" runat="server" class="tdLeftInside" for="" Text="link - http://"></asp:Label>
            <asp:TextBox ID="tbName" runat="server" class="searcxBoxNameInside valid"></asp:TextBox>
        </div>
        <div style="clear:both"></div>
        <div class="inputDiv">
            <asp:Label ID="Label3" runat="server" class="tdLeftInside" for="" Text="Is Active:"></asp:Label>
            <asp:CheckBox ID="cbActive" runat="server" class="span_form valid" TextAlign="Left"  />
        </div>
        <div style="clear:both"></div>
        <div class="inputDiv">
            <asp:Label ID="Label4" runat="server" class="tdLeftInside" for="" Text="position:"></asp:Label>
            <asp:RadioButton ID="rbRight" Text="right" Checked="true" GroupName="position"   
                CssClass="span_form" runat="server" />
            <asp:RadioButton ID="rbBottom" Text="bottom" GroupName="position" CssClass="tdLeftInside_banners span_form" runat="server" />
        </div>
        <div style="clear:both"></div>
        <div class="inputDiv">
            <asp:Label ID="Label5" runat="server" class="tdLeftInside" for="" Text="order:"></asp:Label>
            <asp:TextBox ID="tbOrder" runat="server" class="searcxBoxNameInside valid"></asp:TextBox>
        </div>
        <div style="clear:both"></div>
        <div class="inputDiv">
            <asp:Button ID="btnSave" CssClass="button left_margin" runat="server" 
                Text="Submit" onclick="btnSave_Click" />
        </div>
        <br />
        <div style="clear:both"></div>
        <asp:GridView ID="gvBanners" runat="server" AutoGenerateColumns="False" 
        BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" 
        CellPadding="4" ForeColor="Black" GridLines="Vertical" 
        onrowdatabound="gvBanners_RowDataBound" Width="1080px" 
        onrowcommand="gvBanners_RowCommand" onrowdeleting="gvBanners_RowDeleting" 
        onrowupdating="gvBanners_RowUpdating">
            <RowStyle BackColor="#F7F7DE" />
            <Columns>
                <asp:TemplateField HeaderText="image">
                    <ItemTemplate>
                        <asp:Image ID="imgBanner" runat="server" />
                        <asp:HiddenField ID="hfId" runat="server" Value='<%# Bind("id") %>' />
                        
                        <asp:HiddenField ID="hfFilename" runat="server" 
                            Value='<%# Bind("filename") %>' />
                        
                    </ItemTemplate>
                    <ItemStyle Width="25%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="link">
                    <ItemTemplate>
                        <asp:HiddenField ID="hfLink" runat="server" Value='<%# Bind("link") %>' />
                        <asp:TextBox ID="tbLink" runat="server"></asp:TextBox>
                    </ItemTemplate>
                    <ItemStyle Width="25%" />
                </asp:TemplateField>
                <asp:CheckBoxField DataField="isActive" HeaderText="is active" Text="is active" 
                    ReadOnly="false">
                <ItemStyle Width="10%" />
                </asp:CheckBoxField>
                <asp:TemplateField HeaderText="position">
                    <ItemTemplate>
                        <asp:RadioButtonList ID="rbPosition" runat="server" >
                            <asp:ListItem Value="true">right</asp:ListItem>
                            <asp:ListItem Value="false">bottom</asp:ListItem>
                        </asp:RadioButtonList>
                        <asp:HiddenField ID="hfPosition" runat="server" 
                            Value="<%# Bind('position') %>" />
                    </ItemTemplate>
                    <ItemStyle Width="10%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="order">
                    <ItemTemplate>
                        <asp:TextBox ID="tborder1" runat="server" Width="50px"></asp:TextBox>
                        <asp:HiddenField ID="hfOrder" Value="<%# Bind('_order') %>" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:Button ID="Button1" runat="server" CausesValidation="False" 
                            CommandArgument="update" CommandName="Delete" Text="Update" />
                    </ItemTemplate>
                    <ItemStyle Width="10%" />
                </asp:TemplateField>
                <asp:CommandField ShowDeleteButton="True" >
                <ItemStyle Width="10%" />
                </asp:CommandField>
            </Columns>
            <FooterStyle BackColor="#CCCC99" />
            <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
            <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <div style="clear:both"></div>
        <br />
</div>
</asp:Content>
